package com.hualan.servlet;


import com.hualan.service.CommunityListService;
import com.hualan.service.impl.CommunityListServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import java.text.ParseException;

@WebServlet("/community/communityList")
public class CommunityListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取请求参数
        String name = req.getParameter("name");
        String startTime = req.getParameter("startTime");
        String endTime = req.getParameter("endTime");
        String pageNum = req.getParameter("pageNum");
        String pageSize = req.getParameter("pageSize");
        String communityName = req.getParameter("communityName");

        CommunityListService communityListService = new CommunityListServiceImpl();
        String jsonString = null;
        try {
            jsonString = communityListService.communityList(name, startTime, endTime, pageNum, pageSize, communityName);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        //响应给前端
        resp.getWriter().write(jsonString);
    }
}
